package com.jpa.embedded.objects.mappings.tutorial;

import com.jpa.embedded.objects.mappings.tutorial.domain.Artist;
import com.jpa.embedded.objects.mappings.tutorial.domain.Label;
import com.jpa.embedded.objects.mappings.tutorial.service.ArtistService;
import com.jpa.embedded.objects.mappings.tutorial.service.LabelService;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JpaEmbeddedObjectsMappingsTutorial {

    public static void main(String[] args) {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("JpaEmbeddedObjectsMappingsTutorial");
        EntityManager em = emf.createEntityManager();
        ArtistService artistService = new ArtistService(em);
        LabelService labelService = new LabelService(em);

        System.out.println("--- Find artist ---");
        Artist artist = artistService.findArtist(1);
        System.out.println(String.format("Found: %s\n", artist));

        System.out.println("--- Find label ---");
        Label label = labelService.findLabel(1);
        System.out.println(String.format("Found: %s", label));
    }
}
